package pg.engine;

import pg.objetosbasicos.Ponto;

public class Zbuffer {
	public float[][] zbuffer;
	private int lengthX;
	private int lengthY;
	
	public Zbuffer(int lengthX, int lengthY) {				
		this.lengthX = lengthX;
		this.lengthY = lengthY;
		zbuffer = new float[lengthX][lengthY];		
	}
	
	public boolean zBuffering(Ponto p) {
		boolean podePintar = false;
		float x = p.x;
		float y = p.y;
		float z = p.z;
		float zBuffer = zbuffer[(int)x][(int)y];			
		if(z < zBuffer) {
			podePintar = true;				
			this.zbuffer[(int)x][(int)y] = z;
		}
		return podePintar;
	}
	
	public void zBuffering(Ponto[] pontos) {
		for(Ponto p : pontos) {
			zBuffering(p);
		}
	}
}
